/*******************************************************************************
 *
 *      A U D I O   R E C O R D E R   T E S T   P R O C E D U R E
 *
 *      Copyright A Levido 2014 - All Rights Reserved
 *
 ******************************************************************************/



0. TEST FILES
================================================================================

0.1 FAT12 CARD
-----------
FAT12:
    Audio 8kbps.wav
    Audio 16kbps.wav
    Audio 22kbps.wav
    Audio 32kbps.wav
    Audio 44kbps.wav
    Audio 48kbps.wav
    Audio 88kbps.wav
    Audio 96kbps.wav
    [REC]

0.2 FAT16 CARD
-----------
FAT16:
    Audio 8kbps.wav
    Audio 16kbps.wav
    Audio 22kbps.wav
    Audio 32kbps.wav
    Audio 44kbps.wav
    Audio 48kbps.wav
    Audio 88kbps.wav
    Audio 96kbps.wav
    [REC]

0.3 FAT32 CARD
-----------
FAT12:
    [BITRATES]
        Audio 8kbps.wav
        Audio 16kbps.wav
        Audio 22kbps.wav
        Audio 32kbps.wav
        Audio 44kbps.wav
        Audio 48kbps.wav
        Audio 88kbps.wav
        Audio 96kbps.wav
    [BADFILES]
        Text.txt
        Audio.mp4
        Not PCM.wav
        Not 2 Channel.wav
        Bad Bitrate.wav
        Bad Sample Size.wav
        Corrupt.wav
    [LONG FILES]
        1kHz 0dB 5min.wav
        Long Audio.wav
    Audio.wav
    [DIR1]
        Audio.wav
        [DIR2]
            Audio.wav
            [DIR3]
                Audio.wav
                [DIR4]
                    Audio.wav
                    [DIR5]
                        Audio.wav
    [LONG NAMES]
        This is a filename greater than 60 characters in length - really it is ok.wav
        This is a filename greater than 80 characters in length - we should not be able to handle this in any sensible way.wav
        This one is just quite long, but not too long.wav
        [ANOTHER STUPIDLY LONG SUBDIRECTORY NAME]
            This is a filename greater than 60 characters in length - really it is ok.wav
            This one is just quite long, but not too long.wav

0.4 Record Card (FAT32)
-----------------------
RECORD:
    [DIR1]
        [DIR2]
            [DIR3]
                [DIR4]
                    [DIR4]



1. PLAYBACK TESTS
================================================================================


1.1 Bit Rates & Skip Forward
----------------------------

    1.1.1 FAT12 Card
    Play back audio files at 8, 16, 22.05, 24, 32, 44.1, 48, 88.2, 96 kbps
    Use skip forward to move between files
    All files should play cleanly and clearly.

    RESULT:

    1.1.2 FAT16 Card
    Play back audio files at 8, 16, 22.05, 24, 32, 44.1, 48, 88.2, 96 kbps
    Use skip forward to move between files
    All files should play cleanly and clearly.

    RESULT:

    1.1.3 FAT32 Card
    Play back audio files at 8, 16, 22.05, 24, 32, 44.1, 48, 88.2, 96 kbps
    Use skip forward to move between files
    All files should play cleanly and clearly.

    RESULT:


1.2 Bad File types
-------------------

    1.2.1 FAT32 Card
    Attempt to play back files with:
        a) Plain text (not WAV) file
        b) Music file (mp4)
        c) WAV file with non-PCM coding
        d) WAV file with <> 2 channels
        e) WAV file with unsupported bit rate
        f) WAV file with <> 16 bit samples
        g) WAV file with corrupt header

    All files should fail to play and present meaningful error message.

        h) A good WAV file should play afterwards
        i) A good WAV file without the.wav extension should play OK

    RESULT:


1.3 Audio Output
----------------

    1.3.1 Phones Out
    Using a long audio file:
        a) check output with phones
        b) excercise volume control over entire range
        c) excercise mute: play->mute->unmute->stop->play
        d) excercise mute: play->mute->stop->play->unmute
        e) excercise mute: mute->play->unmute->stop

        RESULT:

    1.3.2 Line Out
    Using a long 1kHz, 0dB audio file:
        a) check line output with phones into 10k load
        Should give 1Vrms nominal

        RESULT:


1.4 Pause and Resume
---------------------

    1.4.1 Play Pause and Resume
    Using a long audio file:
        a) exercise pause/resume: play->pause->resume->stop->play
        b) exercise pause/resume: play->pause->stop->play

        RESULT:


1.5 Play from Subdirectories
-----------------------------

    1.5.1 Play from various levels of subdirectory, moving both  down and up the
    directory tree:
        a) play from ROOT:/
        b) play from ROOT:/DIR1/
        c) play from ROOT:/DIR1/DIR2
        d) play from ROOT:/DIR1/DIR2/DIR3
        e) play from ROOT:/DIR1/DIR2/DIR3/DIR4/
        f) play from ROOT:/DIR1/DIR2/DIR3
        g) play from ROOT:/DIR1/DIR2
        h) play from ROOT:/DIR1/
        i) play from ROOT:/

        RESULT:



2. RECORD TESTS
================================================================================


2.1 Bitrates
------------

    2.1.1 FAT12 Card
    Record audio files at 8, 16, 22.05, 24, 32, 44.1, 48, 88.2, 96 kbps
    All files should play cleanly and clearly on the DUT and the PC.

    RESULT:

    2.1.2 FAT16 Card
    Play back audio files at 8, 16, 22.05, 24, 32, 44.1, 48, 88.2, 96 kbps
    All files should play cleanly and clearly on the DUT and the PC.

    RESULT:

    1.1.3 FAT32 Card
    Play back audio files at 8, 16, 22.05, 24, 32, 44.1, 48, 88.2, 96 kbps
    All files should play cleanly and clearly on the DUT and the PC.

    RESULT:


2.2 Record Sources
------------------

    2.2.1 Line In
    Record audio from a 1 kHz signal source at various levels and record gains
        a) Source 2Vrms, Gain 0dB => should play back at 1Vrms
        b) Source 2Vrms, Gain -3dB => should play back at 0.5Vrms
        c) Source 1Vrms, Gain +3dB => should play back at 1Vrms

        RESULT:


    2.2.2 Microphone In
    Record 1KHz audio from Mic Input at each gain level:
        a) Source 40mVrms, Gain 0dB => should play back at 1Vrms
        b) Source 4mVrms, Gain 20dB => should play back at 1Vrms

        RESULT:


    2.2.3 Built-in Microphone
    Test by speaking at normal level 500mm from mic, Gain 20dB. Should play
    back audibly

        RESULT:


    2.2.4 Line and Microphone Mute
    Test mute with both line and mic inputs
    Check the recorded file pauses at the appropriate time
        a) excercise mute: rec->mute->unmute->stop->rec
        b) excercise mute: rec->mute->stop->rec->unmute
        c) excercise mute: mute->rec->unmute->stop

        RESULT:


    2.2.5 Record Pause and Resume
    Check the recorded file pauses at the appropriate time
        a) exercise pause/resume: rec->pause->resume->stop->rec
        b) exercise pause/resume: rec->pause->stop->rec

        RESULT:



3. Configuration
================================================================================

3.1 Display Backlight
---------------------

    Excercise all backlight levels. Should not be able to dim backlight
    completely.

        RESULT:


 3.2 Time and Date
-----------------------

    3.2.1 Set Time
    Excercise time settings to ensure proper rollover and valid values
        a) Hours
        b) Minutes
        c) Seconds

        RESULT:


    3.2.2 Set Date
    Excercise Date settings to ensure proper rollover and valid values
        a) Years
        b) Months
        c) Days

        RESULT:


    3.2.3 Time Accuracy
    See 4.1.5 below.


        RESULT:


3.3 About Screen
----------------

    Excercise help screen.

        RESULT:



4. Power Management
================================================================================

4.1 Battery Power
-----------------

    4.1.1 Battery Level
    Apply a variable voltage in place of the battery. adjusts slowly from 4.2V
    down to 2.5 and back:
        a) HIGH->FAIR at  ~3.7V
        b) FAIR-<LOW  at  ~3.4V
        c) LOW->Shutdown at  ~2.8V
        d) Shutdown->LOW at  ~2.8V
        e) LOW->FAIR  at  ~3.4V
        f) FAIR->HIGH at  ~3.7V

        RESULT:


    4.1.2 Dim and Sleep
        a) Display should dim ~30 sec after last touch
        b) DUT should sleep ~30 seconds after dimming unless
            i)   touched
            ii)  playing
            iii) recording
            iv)  USB powered
        c) Current consumption from battery (without USB power) in sleep should
        be less than 500uA

        RESULT:


    4.1.3 Run to flat
    Charge battery to LOW status and run to flat by recording a long file. DUT
    must shutdown before battery voltage falls below 2.8 V and the recorded
    file should be properly closed.

        RESULT:


    4.1.4 Charge
    With USB connected and not playing or recording. Screen should show CHRG
    while charging and FULL when charged
        a) Battery should charge from Shutdown->full in xx Hours
        a) Battery should charge from LOW->full in xx Hours
        a) Battery should charge from HIGH->full in xx Hours

        RESULT:


    4.1.5 Long Sleep
    With battery charged to HIGH status, allow the DUT to sleep for 7 days.
    Should power up normally after this time, with time and date correct.
    See 3.2.3 time should be accurate within 5 minutes.

        RESULT:



5. USB Operation
================================================================================

5.1 Connection & File Transfer
------------------------------

    5.1.1 Connect USB to a PC. Press USB button. DUT should enter USB mode.
    SD card should become visible. From PC check that:
        a) Files can be written
        b) Files can be read
        c) Files can be moved
        d) Files can be erased
        e) Directories can be created
        f) Directories can be erased

        RESULT:


5.2 Unplugging and Ejection
---------------------------

    5.2.1 Normal Disconnection
        a) Eject DUT volume on PC -> DUT should come out of USB mode
        b) Cancel USB mode on DUT -> DUT should come out of USB mode (The PC
        may give a warning about incorrect ejection of the volume)
        c) Disconnect USB cable -> DUT should come out of USB mode (The PC
        may give a warning about incorrect ejection of the volume)

        RESULT:


    5.2.2 Sleep
        a) Connect DUT to PC and enter USB mode. Allow PC to enter sleep mode.
        -> DUT should come out of USB mode, and remain so when PC wakes.
        a) Connect DUT to PC and enter USB mode. Power off PC.
        -> DUT should come out of USB mode, and remain so when PC turned on.

        RESULT:


5.4 Power Drawn
---------------



6. Stress Tests
================================================================================

6.1 Long File & Directory Names/Levels
--------------------------------------

    6.1.1 Long File Name
    The DUT can handle long file names up to 80 characters
        a) Attempt to play a long file name < 80 characters. Should display
        and play OK
        b) File name > 80 chars should fail gracefully

    RESULT:


    6.1.2 Long Path Names
    The DUT can handle long path names up to 80 characters
        a) Attempt to play a long file with path name < 80 characters.
        Should display and play OK
        b) Path name > 80 chars should fail gracefully

        RESULT:


6.2 Record to End of Disc
-------------------------

    6.2.1 Full disk
    A file recording to the end of a full disk should throw an error and close
    the file so it can be played.

        RESULT:


6.3 Remove SD Card Unexpectedly
-------------------------------

    6.3.1 Remove SD card:
        a) While idle => error message and no file corruption
        b) While playing => error message and no file corruption
        c) While recording => error message. File may be corrupted.

        RESULT:


6.4 Highly Fragmented Cards
----------------------------

    6.4.1 With a highly fragmented card (ie one in which many files have been
    stored and erased):
        a) Recording works at up to 48kbps
        b) Playback works at up to 96 kbps

        RESULT:
